![]() ![]() ![]() |
Both in-place and copying versions are provided for certain algorithms.
The decision whether to include a copying version was usually based
on complexity considerations.
When the cost of doing the operation dominates the cost of copy,
the copying version is not included. For example, sort_copy
is not included since the cost of sorting is much more significant,
and users might as well do copy
followed by sort
.
When such a version is provided for algorithm it is called a
algorithm_copy
.
The Predicate1
class is used whenever an algorithm expects
a function object that when applied to the result of dereferencing the
corresponding iterator returns a value convertible to boolean
.
In other words, if an algorithm takes Predicate1 pred
as
its argument and first
as its iterator argument,
it should work correctly in the construct
if (pred.compare(first.get())){...}
.
The Predicate2
class is used whenever an algorithm
expects a function object that when applied to the result of dereferencing
two corresponding iterators or to dereferencing an iterator and an object
x
returns a value convertible to boolean
.
In other words, if an algorithm takes Predicate2 pred
as its argument and first1
and first2
as its
iterator arguments, it should work correctly in the construct
if (pred.compare(first.get(), first2.get())) {...}
.
Predicate2
always takes the first iterator type as its
first argument, that is, in those cases when Object x
is part
of the signature, it should work correctly in the context of
if (pred.compare(first.get(), x)) {...}
.
All the algorithms are implemented as static methods in the Algo api class.
![]() ![]() ![]() |